I'm writing a program to make sure I understand the for statement. It is a program that computes the resistance of a network of resistors. I get the following error.
error: expected unqualified-id before '{' token
I am using code blocks on XP with the G++ compiler.
Code:
#include <iostream>
using namespace std;
int resitors; //amount of resistors the user enters
float resistance; //the output value, the resistance of the resistors in ohms
int resistor_value; //allows user to input value of resistors one at a time
int counter; //used to count
{
resistance = 0;
resist = 0; //initializing variables
cout << "How many resistors?\n";
cin >> resistors;
for ( resitors < counter, ++counter)
{
cout << "What is the resistence of the number " << counter << " resistor?\n";
cin >> resistor_value;
resist += resistor_value;
}
resistance = (resist / resitors);
cout << "The resistence is " << resistance << " ohms.\n";
return(0);
}
Thanks in advance,
fhbwghads